/*
 * HTMLParser.h
 *
 *  Created on: 2010-6-10
 *      Author: guobc
 */

#ifndef HTMLPARSER_H_
#define HTMLPARSER_H_

#include "AbstractParser.h"
#include "HTMLLexer.h"

namespace HA {
class HTMLParser: public HA::AbstractParser {
public:
	/**
	 * Construct method.
	 * @param lexer The lexer that can construct a token.
	 */
	HTMLParser(Lexer* lexer);

	/**
	 * Parse character stream.
	 */
	void parse() throw (ParserException);

	/**
	 * Get root node after parsing.
	 * @return
	 */
	inline Element* getRootNode() {
		return mRoot;
	}

private:
	/**
	 * Parse comment and DOCTYPE element.
	 */
	void parseCommentOrDoctype() throw(ParserException);

	Tag parseTag(bool& beginTag, Token& token) throw(ParserException);

	Element& parseJSP(bool& beginTag, Token& token) throw(ParserException);

	Text& parseString(bool& beginTag, Token& token) throw(ParserException);

	bool skipWhiteSpace();

private:
	Element* mRoot;
};
}
#endif /* HTMLPARSER_H_ */
